package com.kai.awt.component;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @Author Mr.Yan
 * @create 2022/3/20 14:53
 * @description:
 */
public class Demo2 {
    public static void main(String[] args) {
        Frame frame = new Frame("dialog");

        Dialog d1 = new Dialog(frame, "模式", true);
        d1.setBounds(0,0,500,500);
        Box verticalBox = Box.createVerticalBox();
        verticalBox.add(new TextArea());
        verticalBox.add(new Button("enter"));
        d1.add(verticalBox);
        Dialog d2 = new Dialog(frame, "非模式", false);
        d2.setBounds(0,0,500,500);



        Button button1 = new Button("模式");
        Button button2 = new Button("非模式");

        frame.add(button1,BorderLayout.NORTH);
        frame.add(button2);

        button1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                d1.setVisible(true);
            }
        });
        button2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                d2.setVisible(true);
            }
        });

        frame.pack();
        frame.setVisible(true);

    }
}
